<?php

class Application_Form_ChangePassword extends Zend_Form {

    public function init() {
        $this->setAction('/admin/account/change')
                ->setMethod('post')
                ->setAttrib('id', 'passwordChangeForm')
                ->addElementPrefixPath('ZendBlog_Validate', 'ZendBlog/validate/', 'validate')
                ->setDecorators(ZendBlog_Decorator_Decorator::Form());

        /* Current Password */
        $this->addElement('password', 'current_password', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Current Password',
            'validators' => array('Password',
                array('stringLength', true, array(4))
            ),
            'filter' => 'StringTrim',
            'required' => true
        ));

        /* Password */
        $this->addElement('password', 'password', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'New Password',
            'validators' => array('PasswordConfirmation',
                array('stringLength', true, array(4))
            ),
            'filter' => 'StringTrim',
            'required' => true
        ));

        /* Confirm Password */
        $this->addElement('password', 'password_confirm', array(
            'decorators' => ZendBlog_Decorator_Decorator::Element(),
            'label' => 'Confirm Password',
            'validators' => array('PasswordConfirmation',
                array('stringLength', true, array(4))
            ),
            'filter' => 'StringTrim',
            'required' => true
        ));
        
        /* Hidden Id */
        $this->addElement('hidden', 'id', array(
            'validators' => array('Digits'),
            'required' => true
        ));

        /* Change button */
        $this->addElement('submit', 'Change', array(
            'decorators' => ZendBlog_Decorator_Decorator::Submit()
        ));
    }
}

